﻿@{
    ViewBag.Title = "WD.Db.Contract.Rbac_FunctionModel_Create";
    Layout = "~/Views/Shared/_LayoutEdit.cshtml";
}


<ul id="treeFunctionModelNodes" class="ztree lileft"></ul>


<div class="clearfix"></div>

<script>

    var setting = {
        check: {
            enable: true,
            chkStyle: "checkbox",
            chkboxType: { "Y": "ps", "N": "ps" }
        }
    };

    $(document).ready(function () {
        $.fn.zTree.init($("#treeFunctionModelNodes"), setting, $.parseJSON('@Html.Raw(ViewBag.Nodes)'));
    });


    function SaveFunctionModelNodes(callback) {
        var treeObj = $.fn.zTree.getZTreeObj("treeFunctionModelNodes");
        var nodes = treeObj.getCheckedNodes(true);
        var ids = "";
        for (var i = 0; i < nodes.length; i++) {
            ids += nodes[i].id + ",";
        }
        console.log(ids);
        $.ajaxC({
            url: "@Url.Action("SetFunctionModel")",
            data: { id: "@ViewBag.id", ids: ids },
            success: function (data) {
                msgsuc(data);
            },
            complete: function () {
                if (callback) callback();
            }
        });

    }

</script>


